<?php

declare(strict_types=1);

namespace DreamCat\PropertyAnalysis\Test;

use DreamCat\PropertyAnalysis\DemoClass\DemoInterface;
use DreamCat\PropertyAnalysis\DemoClass\Inner\Demo;
use Dreamcat\PropertyAnalysis\Pojo\BuildinType;
use Dreamcat\PropertyAnalysis\Pojo\OneMayTypeDesc;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

/**
 * -
 * @author vijay
 */
class OneMayTypeTest extends TestCase
{
    public function testOneMay()
    {
        $one = new OneMayTypeDesc(BuildinType::FLOAT);
        self::assertFalse($one->isInterface());
        self::assertFalse($one->isClass());
        self::assertTrue($one->isScalar());

        $one = new OneMayTypeDesc(BuildinType::ARRAY);
        self::assertFalse($one->isInterface());
        self::assertFalse($one->isClass());
        self::assertFalse($one->isScalar());
        self::assertNull($one->getIsMap());

        $one->setIsMap(true);
        self::assertTrue($one->getIsMap());
        $one->setIsMap(false);
        self::assertFalse($one->getIsMap());

        $one = new OneMayTypeDesc(new ReflectionClass(Demo::class));
        self::assertFalse($one->isInterface());
        self::assertTrue($one->isClass());
        self::assertFalse($one->isScalar());

        $one = new OneMayTypeDesc(new ReflectionClass(DemoInterface::class));
        self::assertTrue($one->isInterface());
        self::assertFalse($one->isClass());
        self::assertFalse($one->isScalar());
    }
}

# end of file
